1. Field
One or more embodiments of the present invention relate to a 3-dimensional (3D) graphics processing method, medium and apparatus, and more particularly, to a 3D graphics processing method, medium and apparatus correcting perspective distortion occurring due to perspective projection.
2. Description of the Related Art
A 3-dimensional (3D) graphics processing process can be largely divided into a geometry stage and a rasterization stage.
The geometry stage can be largely divided into a model and view transformation stage, a camera transformation stage, a lighting and shading stage, a projection stage, a clipping stage, and a screen mapping stage. The model and view transformation stage is a technique of transforming a 3D object to a world coordinate system in a 3D space and transforming the 3D object of the world coordinate system to a camera coordinate system based on a point of view (camera). The lighting and shading stage is a process of representing a reflection effect and a shading effect due to a light source in order to enhance realism of the 3D object. The projection stage is a technique of projecting the 3D object of the camera coordinate system onto a 2D screen, and the clipping stage is a technique of clipping a portion of a primitive, which is out of a view volume, in order to transfer only a portion of the primitive, which is within the view volume, to the rasterization stage. The screen mapping stage is a technique of determining coordinates of the projected object when the projected object is output to the 2D screen.
The rasterization stage is a technique for determining correct attribute values for each pixel using coordinates of each vertex, colors, and texture of the 3D object provided from the geometry stage, wherein a triangle is set using information on vertices of the 3D object, and the correct attribute values for each pixel are obtained by performing edge processing and scan line processing in the set triangle.
In particular, the projection stage is a requisite technique in the 3D graphics processing technique and uses an orthographic projection or perspective projection technique. The orthographic projection technique performs projection by arranging one of an x, y, and z axis in a 3D coordinate system to be parallel to a projecting direction and a projection plane to be perpendicular to the axis parallel to the projecting direction. Since an object is projected onto the projection plane while maintaining relative sizes and angles viewed from a perpendicular direction in the orthographic projection technique, the orthographic projection technique is usually used in machine or architecture design. However, since perspective is not expressed in the orthographic projection technique, a realistic screen is not created. Unlike the orthographic projection technique, since projection lines are not parallel to each other in the perspective projection technique, each axis is projected onto a projection plane in a non-perpendicular direction. In the perspective projection technique, since a figure obtained by viewing a 3D object from one point of view (camera) appears on a 2D projection plane, projection lines are pointed to the point of view. If the perspective projection technique is used, since an object located far away from the point of view is projected as a relatively small figure and an object located close to the point of view is projected as a relatively large figure, a realistic projection result can be obtained as if a person directly saw a 3D figure with their own eyes. Thus, if a realistic screen is necessary as in virtual reality, games, and animation, the perspective projection technique is used.
Meanwhile, in the 3D graphics processing technique, the perspective projection technique is performed in a homogeneous coordinate system. The homogeneous coordinate system further uses one dimension added to 3 dimensions, i.e. dot, vector, and matrix. That is, in the homogeneous coordinate system, a point is expressed using four elements x, y, z, and w, instead of three elements x, y, and z. The fourth element w is called a homogeneous coordinate. In the homogeneous coordinate system, perspective projection transformation is performed using a 4×4 matrix, and when coordinates (x′, y′, z′, w) are obtained as a result of the perspective projection transformation, (x, y, z, 1), i.e. (x=x′/w, y=y′/w, z=z′/w, 1), which is a result obtained by dividing the coordinates (x′, y′, z′, w) by the homogeneous coordinate w, become screen coordinates.
If the perspective projection transformation is performed for vertices of a 3D object, in the rasterization stage, attribute values of points other than the vertices are obtained by performing interpolation using attribute values of the vertices. In this case, if a general linear interpolation technique is used, perspective distortion occurs in a color value or texture coordinates. FIG. 1A is a diagram for describing the occurrence principle of perspective distortion in a color value. When two vertices expressed in black and white in FIG. 1A are perspective projected, an intermediate point in the middle of the two vertices is located close to one of the two vertices, e.g. the black point. Although it is normal that the intermediate point close to the black point has a true gray color, a gray color close to black is shown as a result of the interpolation. FIG. 1B shows a case where perspective distortion occurs in texture coordinates. If perspective distortion does not occur, a normal screen shown on the left of FIG. 1B must be displayed as a result of texture mapping. However, if linear interpolation is performed for texture coordinates (u, v), a distorted screen shown on the right of FIG. 1B is displayed.
Correction of this perspective distortion is called perspective correction. A representative perspective correction technique is a hyperbolic interpolation technique. The hyperbolic interpolation technique is based on the fact that attribute values of a pixel, e.g., values obtained by dividing texture coordinates by a homogeneous coordinate w and an inverse value 1/w of the homogeneous coordinate, have a linear characteristic. The hyperbolic interpolation technique will now be schematically described. FIG. 2 is a diagram for describing the hyperbolic interpolation technique. It is assumed that texture coordinates and homogeneous coordinates of both end points 22 and 23 of one scan line 21 of a triangle formed by three vertices are respectively (u1, v1), w1 and (u2, v2), w2 and texture coordinates and a homogeneous coordinate of an arbitrary point of the scan line 21 are (u, v) and w. First, values obtained by dividing texture coordinates by each corresponding homogeneous coordinate and inverse values of the homogeneous coordinates, i.e. (u1/w1, v1/w1), 1/w1, (u2/w2, v2/w2), and 1/w2, are obtained for the both end points 22 and 23. Next, (u/w, v/w) is linear-interpolated using (u1/w1, v1/w1) and (u2/w2, v2/w2), and 1/w is linear-interpolated using 1/w1 and 1/w2. Finally, values obtained by dividing the interpolated (u/w, v/w) by the interpolated 1/w, i.e. {(u/w)/(1/w), (v/w)/(1/w)}, are obtained as texture coordinates of the arbitrary point 24.
In a conventional 3D graphics processing technique, when the perspective correction is performed, the hyperbolic interpolation technique is applied to all pixels on each scan line. The hyperbolic interpolation technique needs division operations, and high computational power is required for these division operations. In particular, since an Advanced Reduced Instruction Set Computer (RISC) Machine Central Processing Unit (ARM CPU) usually used in mobile devices processes various operations using software, a long processing time and high power consumption are required for the division operations. Since an amount of perspective distortion can vary, if the hyperbolic interpolation technique is applied to all pixels without considering the amount of perspective distortion, processing time and power consumption are unnecessarily wasted.